package goleetcode

func minLength(s string) int {
	st := []byte{}
	for i := range s {
		st = append(st, s[i])
		m := len(st)
		if m >= 2 && (string(st[m-2:]) == "AB" || string(st[m-2:]) == "CD") {
			st = st[:m-2]
		}
	}
	return len(st)
}